﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using YArchitech.DataModel;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;

namespace YArchitech.HVAC
{
	public partial class FrmComprhsivPipelineSec : System.Windows.Forms.Form
	{
		public TaggingSetStruct TaggingSet
		{
			get
			{
				return this.taggingSet;
			}
		}

		public FrmComprhsivPipelineSec()
		{
			this.InitializeComponent();
			new YJKProcessTools().ShowInTaskbarChange(this);
			this.userSetting = new HVACUserSetting();
			base.Icon = Resource.YArchitechIcon;
		}

		private void FrmComprhsivPipelineSec_Load(object sender, EventArgs e)
		{
			this.SetInitialization();
		}

		private void btnOk_Click(object sender, EventArgs e)
		{
			this.SetStorage();
			base.DialogResult = DialogResult.OK;
		}

		private void btnCancel_Click(object sender, EventArgs e)
		{
			base.DialogResult = DialogResult.Cancel;
		}

		private void rdoPipeCentre_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rdoPipeCentre.Checked)
			{
				this.taggingSet.SetPipe = true;
			}
		}

		private void rdoPipeOuter_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rdoPipeOuter.Checked)
			{
				this.taggingSet.SetPipe = false;
			}
		}

		private void rdoDuctCentre_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rdoDuctCentre.Checked)
			{
				this.taggingSet.SetDuct = true;
			}
		}

		private void rdoDuctOuter_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rdoDuctOuter.Checked)
			{
				this.taggingSet.SetDuct = false;
			}
		}

		private void rdoCableTrayCentre_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rdoCableTrayCentre.Checked)
			{
				this.taggingSet.SetCableTray = true;
			}
		}

		private void rdoCableTrayOuter_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rdoCableTrayOuter.Checked)
			{
				this.taggingSet.SetCableTray = false;
			}
		}

		private void rdoConduitCentre_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rdoConduitCentre.Checked)
			{
				this.taggingSet.SetConduit = true;
			}
		}

		private void rdoConduitOuter_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rdoConduitCentre.Checked)
			{
				this.taggingSet.SetConduit = false;
			}
		}

		private void SetInitialization()
		{
			string text = this.userSetting.ReadValue("TagOfComprhsivPipelineSetValue", "TaggingPipeSet");
			string text2 = this.userSetting.ReadValue("TagOfComprhsivPipelineSetValue", "TaggingDuctSet");
			string text3 = this.userSetting.ReadValue("TagOfComprhsivPipelineSetValue", "TaggingCableTraySet");
			string text4 = this.userSetting.ReadValue("TagOfComprhsivPipelineSetValue", "TaggingConduitSet");
			if (!(text != "") || !(text2 != "") || !(text3 != "") || !(text4 != ""))
			{
				this.rdoPipeCentre.Checked = true;
				this.rdoDuctCentre.Checked = true;
				this.rdoCableTrayCentre.Checked = true;
				this.rdoConduitCentre.Checked = true;
				return;
			}
			this.taggingSet.SetPipe = Convert.ToBoolean(text);
			this.taggingSet.SetDuct = Convert.ToBoolean(text2);
			this.taggingSet.SetCableTray = Convert.ToBoolean(text3);
			this.taggingSet.SetConduit = Convert.ToBoolean(text4);
			if (this.taggingSet.SetPipe)
			{
				this.rdoPipeCentre.Checked = true;
			}
			else
			{
				this.rdoPipeOuter.Checked = true;
			}
			if (this.taggingSet.SetDuct)
			{
				this.rdoDuctCentre.Checked = true;
			}
			else
			{
				this.rdoDuctOuter.Checked = true;
			}
			if (this.taggingSet.SetCableTray)
			{
				this.rdoCableTrayCentre.Checked = true;
			}
			else
			{
				this.rdoCableTrayOuter.Checked = true;
			}
			if (this.taggingSet.SetConduit)
			{
				this.rdoConduitCentre.Checked = true;
				return;
			}
			this.rdoConduitOuter.Checked = true;
		}

		private void SetStorage()
		{
			this.taggingSet.SetPipe = this.rdoPipeCentre.Checked;
			this.taggingSet.SetDuct = this.rdoDuctCentre.Checked;
			this.taggingSet.SetCableTray = this.rdoCableTrayCentre.Checked;
			this.taggingSet.SetConduit = this.rdoConduitCentre.Checked;
			this.userSetting.WriteValue("TagOfComprhsivPipelineSetValue", "TaggingPipeSet", this.taggingSet.SetPipe.ToString());
			this.userSetting.WriteValue("TagOfComprhsivPipelineSetValue", "TaggingDuctSet", this.taggingSet.SetDuct.ToString());
			this.userSetting.WriteValue("TagOfComprhsivPipelineSetValue", "TaggingCableTraySet", this.taggingSet.SetCableTray.ToString());
			this.userSetting.WriteValue("TagOfComprhsivPipelineSetValue", "TaggingConduitSet", this.rdoConduitCentre.Checked.ToString());
		}

		private TaggingSetStruct taggingSet = new TaggingSetStruct();

		private HVACUserSetting userSetting;
	}
}
